package com.ycl.job.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ycl.job.service.impl.BaseJobImportTypeServiceImpl;
import com.zbf.common.entity.ResponseResult;
import com.zbf.common.entity.my.BaseImportTask;
import com.zbf.common.entity.my.BaseJobImportType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 袁成龙
 * @since 2020-10-25
 */
@RestController
@RequestMapping("/baseJobImportType")
public class BaseJobImportTypeController {

    ResponseResult responseResult=new ResponseResult();

    @Autowired
    private BaseJobImportTypeServiceImpl typeService;

    @RequestMapping("/importlist")
    public ResponseResult responseResult(String lei,String miao){
        QueryWrapper queryWrapper = new QueryWrapper();
        if(lei!=null&&!"".equals(lei)){
            queryWrapper.eq("import_class",lei);
        }
        if(miao!=null&&!"".equals(miao)){
            queryWrapper.like("import_mark",miao);
        }
        List<BaseJobImportType> list1 = typeService.list(queryWrapper);
        System.out.println(list1.size());
        responseResult.setResult(list1);
        return responseResult;
    }
    
    /**
     * @Author 袁成龙
     * @Description //TODO 添加导入的Job
     * @Date 14:52 2020/10/25
     * @Param 
     * @return 
     **/
    @RequestMapping("/addtask")
    public ResponseResult result(@RequestBody BaseJobImportType importTask){
        BaseJobImportType baseJobImportType = new BaseJobImportType();
        baseJobImportType.setImportMark(importTask.getImportMark());
        baseJobImportType.setImportClass(importTask.getImportClass());
        baseJobImportType.setCreateTime(LocalDateTime.now());
        typeService.save(baseJobImportType);
        responseResult.setCode(1006);
        return responseResult;
    }

}

